package drds.configuration.db.xml_mapping.dynamic_tag.tag_context;

import ognl.OgnlContext;
import ognl.PropertyAccessor;

import java.util.Map;


class TagContextPropertyAccessor implements PropertyAccessor {

    @Override
    public Object getProperty(Map context, Object target, Object name) {
        Map map = (Map) target;
        Object result = map.get(name);
        if (map.containsKey(name) || result != null) {
            return result;
        }
        Object parameterObject = map.get(TagContext.parameter_key);
        if (parameterObject instanceof Map) {
            return ((Map) parameterObject).get(name);
        }
        return null;
    }

    @Override
    public void setProperty(Map context, Object target, Object name, Object value) {
        Map<Object, Object> map = (Map<Object, Object>) target;
        map.put(name, value);
    }

    @Override
    public String getSourceAccessor(OgnlContext arg0, Object arg1, Object arg2) {
        return null;
    }

    @Override
    public String getSourceSetter(OgnlContext arg0, Object arg1, Object arg2) {
        return null;
    }
}
